package com.whzm.mapper;

import com.whzm.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    /**
     * 根据用户注册电话去查找用户是否存在
     * 找到则返回一条用户信息，否则返回null
     * @param phone
     * @return
     */
    @Select("select * from flow_user where phone=#{phone}")
    User searchInfoByPhone(String phone);

    /**
     * 添加一条用户信息(role_id不设置)
     * @param user
     * @return
     */
    @Insert("insert into flow_user(id,username,phone,password,type,status,wechat,is_deleted) values(#{id},#{username},#{phone},#{password},#{type},#{status},#{wechat},#{isDeleted})")
    Integer addUser(User user);

    /**
     * 根据userId获取一条user信息
     * @param userId
     * @return
     */
    @Select("select * from flow_user where id=#{userId}")
    User getUserById(String userId);
}
